/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package bankowosc;

import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Calendar;

import javax.swing.JButton;
import bankowosc.dane.Klient;
import bankowosc.dane.Lokata;
import bankowosc.dane.Rachunek;
import bankowosc.dane.Rodzaj_lokaty;
import bankowosc.polaczenie.KlientBD;
import bankowosc.polaczenie.LokataStatements;
import bankowosc.polaczenie.RachunekBD;
import bankowosc.polaczenie.UmowaBD;
import bankowosc.polaczenie.polacz;

import javax.swing.DefaultComboBoxModel;
import javax.swing.GroupLayout.Alignment;
import javax.swing.ComboBoxModel;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.JPanel;
import javax.swing.GroupLayout;

import com.toedter.calendar.JDateChooser;

/**
 *
 * @author Cyga
 */
public class Okno1 extends javax.swing.JFrame {
	
	LokataStatements lok = new LokataStatements();
	ArrayList<Lokata> noweLokaty = lok.selectAllLokata(p);
	ArrayList<Rodzaj_lokaty> wszystkieLokaty = lok.selectAllRodzajLokaty(p);
	ArrayList<Lokata> wszystkieLokatyKlienta;
	private int idKlienta;
	private int idZm;
	private int idRodzaju;
	private Double minKwota2;
	private Double maxKwota2;
	private BigDecimal idLokaty;
	private String statusLokaty;
	private BigDecimal rachunekDoWyplaty;
	private int id_waluty;
	private Double kwota;
	
    /**
     * Creates new form Okno
     */

    private JPanel panelLokata;
    
    public Okno1() {
        initComponents();
        
        
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
                            
    private void initComponents() {

    	setSize(800, 600);
    	setTitle("Bank");
    	
        jTabbedPane1 = new javax.swing.JTabbedPane();
        LogowaniePanel = new javax.swing.JPanel();
        RORPanel = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        LokataPanel = new javax.swing.JPanel();
        KredytPanel = new KredytPanel(p);
        UbezpieczeniePanel = new UbezpieczeniePanel(p);
        KartaPanel = new javax.swing.JPanel();
        dataRozpoczeciaChooser = new JDateChooser();
        dataZakonczeniaChooser = new JDateChooser();
		

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setPreferredSize(new java.awt.Dimension(800, 600));

        jLabel1.setText("Rachunki:");

        javax.swing.GroupLayout RORPanelLayout = new javax.swing.GroupLayout(RORPanel);
        RORPanel.setLayout(RORPanelLayout);
        RORPanelLayout.setHorizontalGroup(
            RORPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(RORPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 175, Short.MAX_VALUE)
                .addComponent(jLabel2)
                .addGap(78, 78, 78))
        );
        RORPanelLayout.setVerticalGroup(
            RORPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(RORPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(RORPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jLabel2))
                .addContainerGap(292, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("ROR", RORPanel);
        PrzelewPanel = new javax.swing.JPanel();
        final JPanel panel = new JPanel();
   
        JButton btnPrzelewJednorazowy = new JButton("Przelew jednorazowy");
        btnPrzelewJednorazowy.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
                          
				TransakcjePanel t= new TransakcjePanel(p, panel,rachunki);
                                t.Przelew_jednorazowy();
                              panel.repaint();
			}
		});
        
        JButton btnPrzelewyStae = new JButton("Przelewy stałe");
        btnPrzelewyStae.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
                          
				TransakcjePanel t= new TransakcjePanel(p, panel,rachunki);
                                t.Przelewy_stale();
                                panel.repaint();
                              
			}
		});
        JButton btnPolecenieZapaty = new JButton("Polecenie zapłaty");
        btnPolecenieZapaty.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
                          
				TransakcjePanel t= new TransakcjePanel(p, panel,rachunki);
                                t.Polecenie_zaplaty();
                                panel.repaint();
                              
			}
		});
   
        
        javax.swing.GroupLayout PrzelewPanelLayout = new javax.swing.GroupLayout(PrzelewPanel);
        PrzelewPanelLayout.setHorizontalGroup(
        	PrzelewPanelLayout.createParallelGroup(Alignment.LEADING)
        		.addGroup(PrzelewPanelLayout.createSequentialGroup()
        			.addContainerGap()
        			.addGroup(PrzelewPanelLayout.createParallelGroup(Alignment.LEADING)
        				.addComponent(panel, GroupLayout.DEFAULT_SIZE, 759, Short.MAX_VALUE)
        				.addGroup(PrzelewPanelLayout.createSequentialGroup()
                                               
                                                .addPreferredGap(ComponentPlacement.UNRELATED)
        					.addComponent(btnPrzelewJednorazowy)
        					.addPreferredGap(ComponentPlacement.UNRELATED)
        					.addComponent(btnPrzelewyStae)
        					.addPreferredGap(ComponentPlacement.UNRELATED)
        					.addComponent(btnPolecenieZapaty)))
        			.addContainerGap())
        );
        PrzelewPanelLayout.setVerticalGroup(
        	PrzelewPanelLayout.createParallelGroup(Alignment.LEADING)
        		.addGroup(PrzelewPanelLayout.createSequentialGroup()
        			.addContainerGap()
        			.addGroup(PrzelewPanelLayout.createParallelGroup(Alignment.BASELINE)
                                       
        				.addComponent(btnPrzelewJednorazowy)
        				.addComponent(btnPrzelewyStae)
        				.addComponent(btnPolecenieZapaty))
        			.addPreferredGap(ComponentPlacement.RELATED)
        			.addComponent(panel, GroupLayout.DEFAULT_SIZE, 482, Short.MAX_VALUE)
        			.addContainerGap())
        );
        PrzelewPanel.setLayout(PrzelewPanelLayout);
        jTabbedPane1.addTab("Transakcje", PrzelewPanel);

        LokataPanel = new javax.swing.JPanel();
        
        panelLokata = new JPanel();
        
        JButton btnNowaLokata = new JButton("Nowa Lokata oraz przegląd lokat");
        btnNowaLokata.addActionListener(new BtnNowaLokataActionListener());
        
        JButton btnZarzadzajLokatami = new JButton("Zarządzaj lokatami");
        btnZarzadzajLokatami.addActionListener(new BtnZarzadzajLokatamiActionListener());
        
        JButton btnPrzegladOferty = new JButton("Symulacja");
        btnPrzegladOferty.addActionListener(new BtnPrzegladOfertyActionListener());
        
        javax.swing.GroupLayout LokataPanelLayout = new javax.swing.GroupLayout(LokataPanel);
        LokataPanelLayout.setHorizontalGroup(
        	LokataPanelLayout.createParallelGroup(Alignment.LEADING)
        		.addGroup(LokataPanelLayout.createSequentialGroup()
        			.addContainerGap()
        			.addGroup(LokataPanelLayout.createParallelGroup(Alignment.LEADING)
        				.addComponent(panelLokata, GroupLayout.DEFAULT_SIZE, 759, Short.MAX_VALUE)
        				.addGroup(LokataPanelLayout.createSequentialGroup()
        					.addComponent(btnNowaLokata)
        					.addPreferredGap(ComponentPlacement.UNRELATED)
        					.addComponent(btnZarzadzajLokatami)
        					.addPreferredGap(ComponentPlacement.UNRELATED)
        					.addComponent(btnPrzegladOferty)))
        			.addContainerGap())
        );
        LokataPanelLayout.setVerticalGroup(
        	LokataPanelLayout.createParallelGroup(Alignment.LEADING)
        		.addGroup(LokataPanelLayout.createSequentialGroup()
        			.addContainerGap()
        			.addGroup(LokataPanelLayout.createParallelGroup(Alignment.BASELINE)
        				.addComponent(btnNowaLokata)
        				.addComponent(btnZarzadzajLokatami)
        				.addComponent(btnPrzegladOferty))
        			.addPreferredGap(ComponentPlacement.RELATED)
        			.addComponent(panelLokata, GroupLayout.DEFAULT_SIZE, 482, Short.MAX_VALUE)
        			.addContainerGap())
        );
        LokataPanel.setLayout(LokataPanelLayout);

        jTabbedPane1.addTab("Lokata", LokataPanel);

        javax.swing.GroupLayout KredytPanelLayout = new javax.swing.GroupLayout(KredytPanel);
        KredytPanel.setLayout(KredytPanelLayout);
        KredytPanelLayout.setHorizontalGroup(
            KredytPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 395, Short.MAX_VALUE)
        );
        KredytPanelLayout.setVerticalGroup(
            KredytPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 317, Short.MAX_VALUE)
        );

        jTabbedPane1.addTab("Kredyt", KredytPanel);

        javax.swing.GroupLayout UbezpieczeniePanelLayout = new javax.swing.GroupLayout(UbezpieczeniePanel);
        UbezpieczeniePanel.setLayout(UbezpieczeniePanelLayout);
        UbezpieczeniePanelLayout.setHorizontalGroup(
            UbezpieczeniePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 395, Short.MAX_VALUE)
        );
        UbezpieczeniePanelLayout.setVerticalGroup(
            UbezpieczeniePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 317, Short.MAX_VALUE)
        );

        jTabbedPane1.addTab("Ubezpieczenie", UbezpieczeniePanel);

        javax.swing.GroupLayout KartaPanelLayout = new javax.swing.GroupLayout(KartaPanel);
        KartaPanel.setLayout(KartaPanelLayout);
        KartaPanelLayout.setHorizontalGroup(
            KartaPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 395, Short.MAX_VALUE)
        );
        KartaPanelLayout.setVerticalGroup(
            KartaPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 317, Short.MAX_VALUE)
        );

        jTabbedPane1.addTab("Karta", KartaPanel);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTabbedPane1)
        );
               
        /*  for(int i=0; i < iloscDanGlownych; i++){
    		jTabPrzyciski[i].addActionListener(new dodajPotraweListener(i));
       
       }*/
    	
    	jTabbedPane1.setVisible(false);
    	LogowaniePanel.setBounds(0, 0, 1000, 1000);
    	LogowaniePanel.setLayout(null);
    	getContentPane().add(LogowaniePanel);
    	
    	JLabel lblLogin = new JLabel("Login:");
		lblLogin.setBounds(130, 146, 56, 14);
		LogowaniePanel.add(lblLogin);
		
		login_textField = new JTextField();
		login_textField.setBounds(188, 137, 187, 32);
		LogowaniePanel.add(login_textField);
		
		JLabel lblHaso = new JLabel("Hasło:");
		lblHaso.setBounds(130, 189, 46, 14);
		LogowaniePanel.add(lblHaso);
		
		haslo_textField = new JPasswordField();
		haslo_textField.setBounds(188, 180, 187, 32);
		haslo_textField.addActionListener(new HasloActionListener());
		LogowaniePanel.add(haslo_textField);
		
		JButton btnZaloguj = new JButton("Zaloguj");
		btnZaloguj.setBounds(188, 223, 89, 23);
		btnZaloguj.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent arg0) {
				loginToBank();
			}
		});
		LogowaniePanel.add(btnZaloguj);
		Calendar calendar = Calendar.getInstance();
		dataRozpoczeciaChooser.setDate(calendar.getTime());
		dataRozpoczeciaChooser.addPropertyChangeListener(new DataRozpoczeciaListener());
		dataZakonczeniaChooser.getDateEditor().setEnabled(false);
		dataZakonczeniaChooser.getCalendarButton().setEnabled(false);
		dataZakonczeniaChooser.setDate(calendar.getTime());
    }

 
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
    	p = new polacz();
        p.laczZBD();
    	
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Okno1.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Okno1.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Okno1.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Okno1.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Okno1().setVisible(true);
            }
        });
    }
    
    private void initComponentsLokataPanel(JPanel lokataPanel) {

        rodzajLokatyLabel = new javax.swing.JLabel();
        minKwotaLokaty = new javax.swing.JLabel();
        minOkresLokaty = new javax.swing.JLabel();
        oprocentowanieLoatyLabel = new javax.swing.JLabel();
        autOdnLokatyLabel = new javax.swing.JLabel();
        kapOdsetekNaLokacie = new javax.swing.JLabel();
        przelewKwotyLabel = new javax.swing.JLabel();
        kwotaLokatyLabel = new javax.swing.JLabel();
        walutaLabel = new javax.swing.JLabel();
        autOdnowienieCheckBox = new javax.swing.JCheckBox();
        kapOdsetekCheckBox = new javax.swing.JCheckBox();
        oprocentowanieLokatyLabel = new javax.swing.JLabel();
        rodzajLokatyComboBo = new javax.swing.JComboBox();
        minKwotaLokatyLabel = new javax.swing.JLabel();
        okresLokatyComboBox = new javax.swing.JLabel();
        przelewKwotyComboBox = new javax.swing.JTextField();
        kwotaLokatyTextField = new javax.swing.JTextField();
        waluta = new javax.swing.JLabel();
        dataRozpoczeniaLabel = new javax.swing.JLabel();
        dataZakonczeniaLabel = new javax.swing.JLabel();
        jLabel1o = new javax.swing.JLabel();
        nazwaTextField = new javax.swing.JTextField();
        rozpoczecieTextField = new javax.swing.JTextField();
        zakonczeniaTextField = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        dodajRachunekButton = new javax.swing.JLabel();
        jLabel2o = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        ZalozLokateButton = new javax.swing.JButton();
        kwotaWalutaLabel = new javax.swing.JLabel();

        rodzajLokatyLabel.setText("Rodzaj lokaty:");

        minKwotaLokaty.setText("Minimalna kwota lokaty:");

        minOkresLokaty.setText("Okres lokaty:");

        oprocentowanieLoatyLabel.setText("Oprocentowanie lokaty:");

        autOdnLokatyLabel.setText("Automatyczne odnowienie lokaty:");

        kapOdsetekNaLokacie.setText("Kapitalizacja odsetek na lokacie:");

        przelewKwotyLabel.setText("Przelew kwoty na rachunek:");

        kwotaLokatyLabel.setText("Kwota lokaty:");

        walutaLabel.setText("Maksymalna kwota:");

        rodzajLokatyComboBo.setFocusable(false);
        String[] rodzajeLokat = new String[wszystkieLokaty.size()];
        for(int i = 0; i < wszystkieLokaty.size(); i++){
        	rodzajeLokat[i] = wszystkieLokaty.get(i).getNazwa();
        }
        rodzajLokatyComboBo.addItemListener(new ItemChangeListenerRodzajeLokat());
        
        rodzajLokatyComboBo.setModel(new DefaultComboBoxModel<>(rodzajeLokat)); 
        updateNowaLokata();

        dataRozpoczeniaLabel.setText("Data rozpoczęcia:");

        dataZakonczeniaLabel.setText("Data zakończenia:");

        jLabel1o.setText("Nazwa lokaty:");

        jLabel3.setText("jLabel3");

        jLabel5.setText("jLabel5");

        dodajRachunekButton.setText("Niepoprawny numer rachunku");
        dodajRachunekButton.setForeground(Color.red);
        dodajRachunekButton.setVisible(false);

        jLabel2o.setText("Procent zwrotu odsetek (zerwanie):");

        ZalozLokateButton.setText("Załóż lokatę");
        ZalozLokateButton.addActionListener(new ZalozLokateActionListener());


        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(lokataPanel);
        lokataPanel.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(kapOdsetekNaLokacie)
                    .addComponent(oprocentowanieLoatyLabel)
                    .addComponent(autOdnLokatyLabel)
                    .addComponent(rodzajLokatyLabel)
                    .addComponent(minKwotaLokaty)
                    .addComponent(minOkresLokaty)
                    .addComponent(przelewKwotyLabel)
                    .addComponent(kwotaLokatyLabel)
                    .addComponent(walutaLabel)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(dataRozpoczeniaLabel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(dataZakonczeniaLabel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addComponent(jLabel2o)
                    .addComponent(jLabel1o))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                    		.addComponent(dataRozpoczeciaChooser, javax.swing.GroupLayout.PREFERRED_SIZE, 135, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(dataZakonczeniaChooser, javax.swing.GroupLayout.PREFERRED_SIZE, 135, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(kapOdsetekCheckBox, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(autOdnowienieCheckBox, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(rodzajLokatyComboBo, 0, 300, Short.MAX_VALUE)
                                .addComponent(okresLokatyComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(minKwotaLokatyLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(oprocentowanieLokatyLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(przelewKwotyComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(waluta, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGroup(layout.createSequentialGroup()
                                    .addComponent(kwotaLokatyTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(kwotaWalutaLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addComponent(nazwaTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(ZalozLokateButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(dodajRachunekButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(kwotaWalutaLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(rodzajLokatyLabel)
                            .addComponent(rodzajLokatyComboBo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(minKwotaLokaty))
                    .addComponent(minKwotaLokatyLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(minOkresLokaty)
                    .addComponent(okresLokatyComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(oprocentowanieLoatyLabel)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(walutaLabel)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(autOdnLokatyLabel))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(oprocentowanieLokatyLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(waluta, javax.swing.GroupLayout.PREFERRED_SIZE, 13, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(8, 8, 8)
                        .addComponent(autOdnowienieCheckBox)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(kapOdsetekNaLokacie)
                    .addComponent(kapOdsetekCheckBox))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(przelewKwotyLabel)
                    .addComponent(przelewKwotyComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(dodajRachunekButton)
                    )
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(kwotaLokatyLabel)
                    .addComponent(kwotaLokatyTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, 130)
                    .addComponent(kwotaWalutaLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(dataRozpoczeniaLabel)
                    .addComponent(dataRozpoczeciaChooser, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(dataZakonczeniaLabel)
                    .addComponent(dataZakonczeniaChooser, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2o)
                    .addComponent(jLabel4))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1o)
                    .addComponent(nazwaTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(ZalozLokateButton))
                .addContainerGap(30, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void zakonczeniaTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_zakonczeniaTextFieldActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_zakonczeniaTextFieldActionPerformed

    private void ZalozLokateButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ZalozLokateButtonActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_ZalozLokateButtonActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton ZalozLokateButton;
    private javax.swing.JLabel autOdnLokatyLabel;
    private javax.swing.JCheckBox autOdnowienieCheckBox;
    private javax.swing.JLabel dataRozpoczeniaLabel;
    private javax.swing.JLabel dataZakonczeniaLabel;
    private javax.swing.JLabel dodajRachunekButton;
    private javax.swing.JLabel jLabel1o;
    private javax.swing.JLabel jLabel2o;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JCheckBox kapOdsetekCheckBox;
    private javax.swing.JLabel kapOdsetekNaLokacie;
    private javax.swing.JLabel kwotaLokatyLabel;
    private javax.swing.JTextField kwotaLokatyTextField;
    private javax.swing.JLabel kwotaWalutaLabel;
    private javax.swing.JLabel minKwotaLokaty;
    private javax.swing.JLabel minKwotaLokatyLabel;
    private javax.swing.JLabel minOkresLokaty;
    private javax.swing.JTextField nazwaTextField;
    private javax.swing.JLabel okresLokatyComboBox;
    private javax.swing.JLabel oprocentowanieLoatyLabel;
    private javax.swing.JLabel oprocentowanieLokatyLabel;
    private javax.swing.JTextField przelewKwotyComboBox;
    private javax.swing.JLabel przelewKwotyLabel;
    private javax.swing.JComboBox rodzajLokatyComboBo;
    private javax.swing.JLabel rodzajLokatyLabel;
    private javax.swing.JTextField rozpoczecieTextField;
    private javax.swing.JLabel waluta;
    private javax.swing.JLabel walutaLabel;
    private javax.swing.JTextField zakonczeniaTextField;
    
    
    private void initComponentsPosiadaneLokaty(JPanel panelLokata) {

    	posiadaneLabel = new javax.swing.JLabel();
        lokatyComboBox = new javax.swing.JComboBox();
        jLabel41 = new javax.swing.JLabel();
        jLabel42 = new javax.swing.JLabel();
        jLabel43 = new javax.swing.JLabel();
        jLabel44 = new javax.swing.JLabel();
        jLabel45 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jLabel411 = new javax.swing.JLabel();
        kapitalizacjaOdsetekLabel = new javax.swing.JLabel();
        odsetkiNaliczoneLabel = new javax.swing.JLabel();
        odsetkiOgolemLabel = new javax.swing.JLabel();
        rachunekLokatyLabel = new javax.swing.JLabel();
        kwotaLabel = new javax.swing.JLabel();
        dataZakonczeniaLabel2 = new javax.swing.JLabel();
        dataRozpoczeciaLabel = new javax.swing.JLabel();
        okresLokatyLabel = new javax.swing.JLabel();
        nazwaLabel = new javax.swing.JLabel();
        automatyczneOdnowienieLabel = new javax.swing.JLabel();
        przelewOdsetekNaRachunekLabel = new javax.swing.JLabel();
        jButton41 = new javax.swing.JButton();
        jLabel12 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        karneOdsetki = new javax.swing.JLabel();
        karaZaZerwanie = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        oprocentowanieLokatyLabel2 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        kapNaLok = new javax.swing.JLabel();

        posiadaneLabel.setText("Posiadane lokaty:");

        jLabel41.setText("Nazwa:");

        jLabel42.setText("Data zakończenia:");

        jLabel43.setText("Kwota:");

        jLabel44.setText("Data rozpoczęcia:");

        jLabel45.setText("Automatyczne odnowienie lokaty:");

        jLabel6.setText("Kapitalizacja odsetek:");

        jLabel7.setText("Rachunek lokaty:");

        jLabel8.setText("Prognozowane odsetki:");

        jLabel9.setText("Status:");

        jLabel10.setText("Okres lokaty:");

        jLabel411.setText("Przelew odsetek na rachunek:");

        kapitalizacjaOdsetekLabel.setText(" ");

        odsetkiNaliczoneLabel.setText(" ");

        odsetkiOgolemLabel.setText(" ");

        rachunekLokatyLabel.setText(" ");

        kwotaLabel.setText(" ");

        dataZakonczeniaLabel2.setText(" ");

        dataRozpoczeciaLabel.setText(" ");

        okresLokatyLabel.setText(" ");

        nazwaLabel.setText(" ");

        automatyczneOdnowienieLabel.setText(" ");

        przelewOdsetekNaRachunekLabel.setText(" ");

        jButton41.setText("Zerwij lokatę");

        jButton41.addActionListener(new ZerwijLokateActionListener());
        jLabel12.setText("Karne odsetki za zerwanie:");

        jLabel13.setText("Kara za zerwanie lokaty:");

        karneOdsetki.setText(" ");

        karaZaZerwanie.setText(" ");

        jLabel14.setText("Oprocentowanie lokaty:");

        oprocentowanieLokatyLabel2.setText(" ");

        jLabel15.setText("Kapitalizacja na lokacie");

        kapNaLok.setText(" ");
        
        wszystkieLokatyKlienta = lok.selectAllLokataForIdKlient(p, idKlienta);
        String[] lokaty = new String[wszystkieLokatyKlienta.size()];
        for(int i = 0; i < wszystkieLokatyKlienta.size(); i++){
        	lokaty[i] = wszystkieLokatyKlienta.get(i).getNr_rachunku();
        }
        
        lokatyComboBox.setModel(new DefaultComboBoxModel<>(lokaty)); 
        lokatyComboBox.addItemListener(new ItemChangeListenerPosiadaneLokaty());
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(panelLokata);
        panelLokata.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(jLabel8, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jLabel42, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jLabel44, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jLabel10, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jLabel45, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jLabel43, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jLabel7, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jLabel9, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jLabel6, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jLabel411, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addComponent(jLabel41)
                    .addComponent(posiadaneLabel)
                    .addComponent(jLabel12)
                    .addComponent(jLabel13)
                    .addComponent(jLabel14)
                    .addComponent(jLabel15))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(oprocentowanieLokatyLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(kapNaLok, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                .addGap(32, 32, 32)
                                .addComponent(jButton41))
                            .addComponent(lokatyComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 230, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addContainerGap(85, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(nazwaLabel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 75, Short.MAX_VALUE)
                            .addComponent(kapitalizacjaOdsetekLabel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(automatyczneOdnowienieLabel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(przelewOdsetekNaRachunekLabel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(karneOdsetki, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(karaZaZerwanie, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(odsetkiNaliczoneLabel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(odsetkiOgolemLabel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(rachunekLokatyLabel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(kwotaLabel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(dataZakonczeniaLabel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(dataRozpoczeciaLabel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(okresLokatyLabel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addGap(0, 0, Short.MAX_VALUE))))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(posiadaneLabel)
                    .addComponent(lokatyComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel41)
                    .addComponent(nazwaLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel10)
                    .addComponent(okresLokatyLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel44)
                    .addComponent(dataRozpoczeciaLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel42)
                    .addComponent(dataZakonczeniaLabel2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel43)
                    .addComponent(kwotaLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel7)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel8)
                            .addComponent(odsetkiOgolemLabel))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel9)
                            .addComponent(odsetkiNaliczoneLabel))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel6)
                            .addComponent(kapitalizacjaOdsetekLabel))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel45)
                            .addComponent(automatyczneOdnowienieLabel))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel411)
                            .addComponent(przelewOdsetekNaRachunekLabel)))
                    .addComponent(rachunekLokatyLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel12)
                    .addComponent(karneOdsetki))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel13)
                    .addComponent(karaZaZerwanie))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jButton41)
                        .addComponent(oprocentowanieLokatyLabel2))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel14)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel15)
                            .addComponent(kapNaLok))))
                .addContainerGap(44, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel automatyczneOdnowienieLabel;
    private javax.swing.JLabel dataRozpoczeciaLabel;
    private javax.swing.JLabel dataZakonczeniaLabel2;
    private javax.swing.JButton jButton41;
    private javax.swing.JLabel jLabel41;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel411;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel42;
    private javax.swing.JLabel jLabel43;
    private javax.swing.JLabel jLabel44;
    private javax.swing.JLabel jLabel45;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JLabel kapNaLok;
    private javax.swing.JLabel kapitalizacjaOdsetekLabel;
    private javax.swing.JLabel karaZaZerwanie;
    private javax.swing.JLabel karneOdsetki;
    private javax.swing.JLabel kwotaLabel;
    private javax.swing.JComboBox lokatyComboBox;
    private javax.swing.JLabel nazwaLabel;
    private javax.swing.JLabel odsetkiNaliczoneLabel;
    private javax.swing.JLabel odsetkiOgolemLabel;
    private javax.swing.JLabel okresLokatyLabel;
    private javax.swing.JLabel oprocentowanieLokatyLabel2;
    private javax.swing.JLabel posiadaneLabel;
    private javax.swing.JLabel przelewOdsetekNaRachunekLabel;
    private javax.swing.JLabel rachunekLokatyLabel;
    
	    public void loginToBank(){
	    	/*int login = Integer.valueOf(login_textField.getText());
			String haslo = String.valueOf(haslo_textField.getPassword());*/
		    int login = 123456789;
			String haslo = "kowalski";
			KlientBD klientbd = new KlientBD();
			klient = klientbd.zaloguj(p, login, haslo);
			this.idKlienta = klient.getId_klienta();
			if(klient != null) {
			klient_szczegol=klient;
				UmowaBD umowabd = new UmowaBD();
				RachunekBD rachunekbd = new RachunekBD();
				rachunki = rachunekbd.pobierzRachunki(p, umowabd.pobierzUmowy(p, klient.getId_klienta()));
				UbezpieczeniePanel.setKlient(klient);
				UbezpieczeniePanel.setRachunki(rachunki);
				KredytPanel.setKlient(klient);
				KredytPanel.setRachunki(rachunki);
				LogowaniePanel.setVisible(false);
				jTabbedPane1.setVisible(true);
				                                int liczba_rachunkow;
                                 liczba_rachunkow = rachunki.size();
		 JButton[] jTabPrzyciski = new JButton[liczba_rachunkow];
    
    	int enter = 10;
    	int wiersz = 10;
    	int style = Font.BOLD;
    	//Font myFont = new Font();
    	//myFont.setSize(11);
  
    	//font.setSize(10, style);
    	
        

    	for(int i=0; i < liczba_rachunkow; i++){
    		jTabPrzyciski[i] = new JButton("x"+(i+1));
    		jTabPrzyciski[i] = new JButton();
    		jTabPrzyciski[i].setSize(300, 60);
    		
    			enter = enter + 80; 
    			wiersz = 10;
    		
			jTabPrzyciski[i].setLocation(jTabPrzyciski[i].getX()+wiersz, jTabPrzyciski[i].getY()+enter);
			jTabPrzyciski[i].setText("rachunek nr"+rachunki.get(i).getNr_rachunku());
			//jTabPrzyciski[i].setFont(font);
			wiersz += 155;
    		RORPanel.add(jTabPrzyciski[i], i);
        
    	}
        JButton zmiana_hasla = new JButton();
        String nr_rachunku = null;
        String nazwa_konta = null;
        String saldo = null;
        String dostepne_srodki = null;
          for(int i=0; i < jTabPrzyciski.length; i++){
    		jTabPrzyciski[i].addActionListener(new SzczegolyListener(nr_rachunku,nazwa_konta,saldo,dostepne_srodki,klient,rachunki.get(i)));
       
       }
				
			}
	    }
	    
	    private void initComponentsListaLokat(JPanel panelLokata) {

            jComboBox1 = new javax.swing.JComboBox();
            jLabel111 = new javax.swing.JLabel();
            jLabel1111123 = new javax.swing.JLabel();
            jLabel114 = new javax.swing.JLabel();
            kwotaTextField = new javax.swing.JTextField();
            jLabel116 = new javax.swing.JLabel();
            jLabel117 = new javax.swing.JLabel();
            jButton1 = new javax.swing.JButton();
            oprocentowanieLabel = new javax.swing.JLabel();
            minKwotaLabel = new javax.swing.JLabel();
            okresLabel = new javax.swing.JLabel();
            jLabel11 = new javax.swing.JLabel();
            kapitalizacjaLabel = new javax.swing.JLabel();
            jLabel1114 = new javax.swing.JLabel();
            jLabel11118 = new javax.swing.JLabel();
            maxKwotaLabel = new javax.swing.JLabel();
            zyskLabel = new javax.swing.JLabel();
            wartoscLabel = new javax.swing.JLabel();
            oprLabel = new javax.swing.JLabel();
            wakutaLabelDlaKwoty = new javax.swing.JLabel();

            String[] rodzajeLokat = new String[wszystkieLokaty.size()];
	        for(int i = 0; i < wszystkieLokaty.size(); i++){
	        	rodzajeLokat[i] = wszystkieLokaty.get(i).getNazwa();
	        }
	        jComboBox1.setModel(new DefaultComboBoxModel<>(rodzajeLokat)); 
	        jComboBox1.addItemListener(new ItemChangeListenerListaLokat());
            jLabel111.setText("Wybierz lokatę:");

            jLabel1111123.setText("Min. kwota lokaty:");

            jLabel114.setText("Okres:");

            kwotaTextField.setText("  ");
            kwotaTextField.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    kwotaTextFieldActionPerformed(evt);
                }
            });

            jLabel116.setText("Kwota:");

            jLabel117.setText("Zysk:");

            jButton1.setText("Załóż lokatę");

            oprocentowanieLabel.setText(" ");

            minKwotaLabel.setText(" ");

            okresLabel.setText(" ");

            jLabel11.setText("Kapitalizacja:");

            kapitalizacjaLabel.setText(" ");

            jLabel1114.setText("Wartość lokaty:");

            jLabel11118.setText("Waluta:");

            maxKwotaLabel.setText(" ");

            zyskLabel.setText(" ");

            wartoscLabel.setText(" ");

            oprLabel.setText("Oprocentowanie:");

            wakutaLabelDlaKwoty.setText(" ");
            updateListaLokat();

            javax.swing.GroupLayout layout = new javax.swing.GroupLayout(panelLokata);
            panelLokata.setLayout(layout);
            layout.setHorizontalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addContainerGap()
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(layout.createSequentialGroup()
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jLabel111)
                                .addComponent(oprLabel))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(oprocentowanieLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGroup(layout.createSequentialGroup()
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jLabel117)
                                .addComponent(jLabel1114))
                            .addGap(191, 191, 191)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(wartoscLabel)
                                .addComponent(zyskLabel)))
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel1111123)
                                    .addComponent(jLabel114))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(minKwotaLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel11118)
                                    .addComponent(jLabel11)
                                    .addComponent(jLabel116))
                                .addGap(31, 31, 31)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(kwotaTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(wakutaLabelDlaKwoty, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addComponent(kapitalizacjaLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(okresLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(maxKwotaLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))))
                    .addContainerGap(120, Short.MAX_VALUE))
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jButton1)
                    .addGap(129, 129, 129))
            );
            layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addContainerGap()
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel111))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(oprocentowanieLabel)
                        .addComponent(oprLabel))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addComponent(jLabel1111123)
                        .addComponent(minKwotaLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel11118)
                        .addComponent(maxKwotaLabel))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel114)
                        .addComponent(okresLabel))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel11)
                        .addComponent(kapitalizacjaLabel))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(kwotaTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel116)
                        .addComponent(wakutaLabelDlaKwoty))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addComponent(jButton1)
                    .addGap(10, 10, 10)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addComponent(zyskLabel)
                        .addGroup(layout.createSequentialGroup()
                            .addComponent(jLabel117)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(jLabel1114)))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(wartoscLabel)
                    .addContainerGap(114, Short.MAX_VALUE))
            );
        }// </editor-fold>//GEN-END:initComponents

	private void kwotaTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_kwotaTextFieldActionPerformed
	    // TODO add your handling code here:
	}//GEN-LAST:event_kwotaTextFieldActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
	private javax.swing.JButton jButton1;
	private javax.swing.JComboBox jComboBox1;
	private javax.swing.JComboBox jComboBox2;
	private javax.swing.JLabel jLabel11;
	private javax.swing.JLabel jLabel111;
	private javax.swing.JLabel jLabel1111123;
	private javax.swing.JLabel jLabel11118;
	private javax.swing.JLabel jLabel1114;
	private javax.swing.JLabel jLabel114;
	private javax.swing.JLabel jLabel116;
	private javax.swing.JLabel jLabel117;
	private javax.swing.JLabel kapitalizacjaLabel;
	private javax.swing.JTextField kwotaTextField;
	private javax.swing.JLabel maxKwotaLabel;
	private javax.swing.JLabel minKwotaLabel;
	private javax.swing.JLabel okresLabel;
	private javax.swing.JLabel oprLabel;
	private javax.swing.JLabel oprocentowanieLabel;
	private javax.swing.JLabel wakutaLabelDlaKwoty;
	private javax.swing.JLabel wartoscLabel;
	private javax.swing.JLabel zyskLabel;

    // Variables declaration - do not modify  
    private javax.swing.JPanel LogowaniePanel;
    private javax.swing.JPanel KartaPanel;
    private KredytPanel KredytPanel;
    private javax.swing.JPanel LokataPanel;
    private javax.swing.JPanel PrzelewPanel;
    private javax.swing.JPanel RORPanel;
    private UbezpieczeniePanel UbezpieczeniePanel;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JTabbedPane jTabbedPane1;
    private JTextField login_textField;
    private JPasswordField haslo_textField;
    private JDateChooser dataRozpoczeciaChooser;
    private JDateChooser dataZakonczeniaChooser;
    
    private void initComponentsSymulacja(JPanel panelLokata) {
    	jLabel1444 = new javax.swing.JLabel();
        jButton1444 = new javax.swing.JButton();
        jLabel2444 = new JDateChooser();
        Calendar cal = Calendar.getInstance();
        jLabel1444.setText("Data:");

        jLabel2444.setDate(cal.getTime());

        jButton1444.setText("Symuluj");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(panelLokata);
        panelLokata.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(137, 137, 137)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jButton1444)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel1444)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel2444)))
                .addContainerGap(194, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(19, 19, 19)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1444)
                    .addComponent(jLabel2444))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton1444)
                .addContainerGap(238, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1444;
    private javax.swing.JLabel jLabel1444;
    private JDateChooser jLabel2444;
    
    private static polacz p;
    private Klient klient;
    private ArrayList<Rachunek> rachunki;
    private static Klient klient_szczegol;
    private static ArrayList<Rachunek> rachunki_szczegol;
    
    class BtnNowaLokataActionListener implements ActionListener{

		@Override
		public void actionPerformed(ActionEvent arg0) {
			// TODO Auto-generated method stub
			panelLokata.removeAll();
			initComponentsLokataPanel(panelLokata);
			panelLokata.repaint();
		}
    	
    }
    class BtnZarzadzajLokatamiActionListener implements ActionListener{

		@Override
		public void actionPerformed(ActionEvent e) {
			// TODO Auto-generated method stub
			panelLokata.removeAll();
			initComponentsPosiadaneLokaty(panelLokata);
			panelLokata.repaint();
		}
    	
    }
    
    class BtnPrzegladOfertyActionListener implements ActionListener{

		@Override
		public void actionPerformed(ActionEvent e) {
			// TODO Auto-generated method stub
			panelLokata.removeAll();
			initComponentsSymulacja(panelLokata);
			panelLokata.repaint();
		}
    	
    }
    class HasloActionListener implements ActionListener{

		@Override
		public void actionPerformed(ActionEvent e) {
			// TODO Auto-generated method stub
			loginToBank();
		}
    }		
    class ItemChangeListenerRodzajeLokat implements ItemListener{

		@Override
		public void itemStateChanged(ItemEvent e) {
			// TODO Auto-generated method stub
			updateNowaLokata();
		}
    	
    }
    class ItemChangeListenerPosiadaneLokaty implements ItemListener{

		@Override
		public void itemStateChanged(ItemEvent e) {
			// TODO Auto-generated method stub
			updatePosiadaneLokaty();
		}
    	
    }
    
    class ItemChangeListenerListaLokat implements ItemListener{

		@Override
		public void itemStateChanged(ItemEvent e) {
			// TODO Auto-generated method stub
			updateListaLokat();
		}
    	
    }
    
    public void updateNowaLokata(){
    	for(int i = 0;i<wszystkieLokaty.size();i++){
    		System.out.println(rodzajLokatyComboBo.getSelectedItem());
    		System.out.println(wszystkieLokaty.get(i).getNazwa());
			if(wszystkieLokaty.get(i).getNazwa().equals(rodzajLokatyComboBo.getSelectedItem())){
				String walutaWartosc = lok.selectWaluta(p, wszystkieLokaty.get(i).getId_waluty());
				String oprocentowanie = String.valueOf(wszystkieLokaty.get(i).getOprocentowanie());
				String okres = wszystkieLokaty.get(i).getOkresLokaty();
				maxKwota2 = (double) wszystkieLokaty.get(i).getMaksymalnaKwota();
				minKwota2 = (double) wszystkieLokaty.get(i).getMinimalnaKwota();
				String maksKwota = wszystkieLokaty.get(i).getMaksymalnaKwota() + " " + walutaWartosc;
				String procZaZerwanie = String.valueOf(wszystkieLokaty.get(i).getProcent_za_zerwanie() + "%");
				String minKwota = String.valueOf(wszystkieLokaty.get(i).getMinimalnaKwota()) + " " + walutaWartosc;
				updateText(walutaWartosc, oprocentowanie,okres, maksKwota, procZaZerwanie, minKwota);
				System.out.println("ok");
				this.idRodzaju = wszystkieLokaty.get(i).getId_rodzaju_lokaty();
				break;
			}
		}
    }
    
    public void updatePosiadaneLokaty(){
    	for(Lokata lokat: wszystkieLokatyKlienta){
    		if(lokat.getNr_rachunku().equals(lokatyComboBox.getSelectedItem())){
    			Rodzaj_lokaty r = lok.getRodzajLokatyForId(p, lokat.getId_rodzaju_lokaty());
    			nazwaLabel.setText(r.getNazwa());
    			okresLokatyLabel.setText(r.getOkresLokaty());
    			dataRozpoczeciaLabel.setText(lokat.getData_rozpoczecia());
    			dataZakonczeniaLabel2.setText(lokat.getData_zakonczenia());
    			kwotaLabel.setText(lokat.getKwota() + " " + lok.selectWaluta(p, r.getId_waluty()));
    			rachunekLokatyLabel.setText(lokat.getNr_rachunku());
    			Double kwotaObliczona = lokat.getKwota();
    			kwotaObliczona = kwotaObliczona * (100-r.getWartosc_podatku())/100;
    			kwotaObliczona = kwotaObliczona * (r.getOprocentowanie())/100;
    			System.out.println(getIloscMiesiecy(r.getOkresLokaty()));
    			kwotaObliczona = kwotaObliczona * getIloscMiesiecy(r.getOkresLokaty());
    			this.rachunekDoWyplaty = new BigDecimal(lokat.getRachunek_do_wyplaty());
    			DecimalFormat df = new DecimalFormat("#.00");
    			odsetkiOgolemLabel.setText(String.valueOf(df.format(kwotaObliczona)));
    			this.kwota = kwotaObliczona;
    			this.id_waluty = r.getId_waluty(); 
    			this.statusLokaty = lokat.getStatus();
    			odsetkiNaliczoneLabel.setText(statusLokaty);
    			kapitalizacjaOdsetekLabel.setText(r.getSposob_kapitalizacji());
    			if(lokat.getCzy_odnawialna_automatycznie().equals("T")){
    				automatyczneOdnowienieLabel.setText("TAK");
    			}
    			else{
    				automatyczneOdnowienieLabel.setText("NIE");
    			}
    			przelewOdsetekNaRachunekLabel.setText(lokat.getRachunek_do_wyplaty());
    			karaZaZerwanie.setText(r.getKara_za_zerwanie() + " " + lok.selectWaluta(p, r.getId_waluty()));
    			karneOdsetki.setText(r.getProcent_za_zerwanie() + " %");
    			oprocentowanieLokatyLabel2.setText(String.valueOf(r.getOprocentowanie()) + " %");
    			kapNaLok.setText("NIE");
    			
    			this.idLokaty = new BigDecimal(lokat.getNr_lokaty());
    		}
    	}
    }
    
    public void updateListaLokat(){
    	for(Rodzaj_lokaty rodzaje : wszystkieLokaty){
			if(rodzaje.getNazwa().equals(jComboBox1.getSelectedItem())){
				//oprocentowanieLokatyLabel.setText(String.valueOf(rodzaje.getOprocentowanie()) + "%");
				wakutaLabelDlaKwoty.setText(lok.selectWaluta(p, rodzaje.getId_waluty()));
				//okresLabel.setText(String.valueOf(rodzaje.getProcent_za_zerwanie() + "%"));
				kapitalizacjaLabel.setText(rodzaje.getSposob_kapitalizacji());
				System.out.println(rodzaje.getKara_za_zerwanie());
				oprocentowanieLabel.setText(String.valueOf(rodzaje.getOprocentowanie()) + "%");
				System.out.println(rodzaje.getMaksymalnaKwota());
				okresLabel.setText(rodzaje.getOkresLokaty());
				//minKwotaLokaty.setText(String.valueOf(rodzaje.getMinimalnaKwota()));
				System.out.println("ko");
				break;
			}
		}
    }
    
    public double getIloscMiesiecy(String data){
    	if(data.equals("2 miesiące")){ 
    		return new Double(0.16666666666);
    	}
    	else if(data.equals("1 miesiąc")){
    		return new Double(0.08333333);
    	}
    	else if(data.equals("3 miesiące")){
    		return new Double(0.25);
    	}
    	else if(data.equals("6 miesięcy")){
    		return new Double(0.5);
    	}
    	else if(data.equals("12 miesięcy")){
    		return 1.0;
    	}
    	else if(data.equals("1 dzień")){
    		return new Double(1/365);
    	}
    	else if(data.equals("2 lata")){
    		return 2.0;
    	}
    	return 1;
    }
    
    public void zmienDataZakonczenia(String data){
    	Calendar cal = dataRozpoczeciaChooser.getCalendar();
    	if(data.equals("2 miesiące")){    		
    		cal.add(Calendar.MONTH, 2);
    	}
    	else if(data.equals("1 miesiąc")){
    		cal.add(Calendar.MONTH, 1);
    	}
    	else if(data.equals("3 miesiące")){
    		cal.add(Calendar.MONTH, 3);
    	}
    	else if(data.equals("6 miesięcy")){
    		cal.add(Calendar.MONTH, 6);
    	}
    	else if(data.equals("12 miesięcy")){
    		cal.add(Calendar.YEAR, 1);
    	}
    	else if(data.equals("1 dzień")){
    		cal.add(Calendar.DATE, 1);
    	}
    	else if(data.equals("2 lata")){
    		cal.add(Calendar.YEAR, 2);
    	}
    	dataZakonczeniaChooser.setDate(cal.getTime());
    }
    
    private void updateText(String walutaWartosc, String oprocentowanie, String okres, String maks, String proc, String min){
    	oprocentowanieLokatyLabel.setText(oprocentowanie);
		okresLokatyComboBox.setText(okres);
		waluta.setText(maks);
		jLabel4.setText(proc);
		minKwotaLokatyLabel.setText(min);
		kwotaWalutaLabel.setText(walutaWartosc);
    }
    
    public class DataRozpoczeciaListener implements PropertyChangeListener{

		@Override
		public void propertyChange(PropertyChangeEvent arg0) {
			// TODO Auto-generated method stub
			zmienDataZakonczenia(String.valueOf(okresLokatyComboBox.getText()));
		}
    	
    }
    
    public class ZerwijLokateActionListener implements ActionListener{

		@Override
		public void actionPerformed(ActionEvent arg0) {
			// TODO Auto-generated method stub
			if(statusLokaty.equalsIgnoreCase("aktywna")){
				lok.zmienStatusLokaty(p,idLokaty);
				lok.dodajPrzelew(p, rachunekDoWyplaty, kwota, id_waluty);
			}
			
		}
    	
    }
    
    public class ZalozLokateActionListener implements ActionListener{

		@Override
		public void actionPerformed(ActionEvent arg0) {
			// TODO Auto-generated method stub
			System.out.println(przelewKwotyComboBox.getText().trim());
			String nrPrzelewu = przelewKwotyComboBox.getText().replaceAll("\\s+", "");
			if(nrPrzelewu.length()!=26)
				System.out.println("1");
			if(nrPrzelewu.isEmpty())
				System.out.println("2");
			if(!nrPrzelewu.matches("[0-9]{26}"))
				System.out.println("3");
			if((nrPrzelewu.length()!=26  || !nrPrzelewu.isEmpty()) && !nrPrzelewu.matches("[0-9]{26}")){
				dodajRachunekButton.setVisible(true);
			}
			else if(kwotaLokatyLabel.getText().isEmpty() || (Double.parseDouble(kwotaLokatyTextField.getText())<minKwota2 || Double.parseDouble(kwotaLokatyTextField.getText())>maxKwota2)){
				JOptionPane.showMessageDialog(null, "Kwota nie mieści się w granicach tej lokaty lub nie została wpisana","Zła kwota!", JOptionPane.ERROR_MESSAGE);
			}
			else{
				String aut;
				if(autOdnowienieCheckBox.isSelected()){
					aut = "T";
				}
				else{
					aut="N";
				}
				dodajRachunekButton.setVisible(false);
				int idLokaty = lok.getMaxLokataId(p);
				if(przelewKwotyComboBox.getText().trim().isEmpty()){
					if(lok.dodajLokate(p, idLokaty, 1, idRodzaju, idKlienta, dataRozpoczeciaChooser.getCalendar(), dataZakonczeniaChooser.getCalendar(), Double.parseDouble(kwotaLokatyTextField.getText()), null,  nazwaTextField.getText(), aut))
						JOptionPane.showMessageDialog(null, "Dodano nową lokatę dla klienta","Dodano lokatę", JOptionPane.INFORMATION_MESSAGE);
				}
				else{
					if(lok.dodajLokate(p, idLokaty, 1, idRodzaju, idKlienta, dataRozpoczeciaChooser.getCalendar(), dataZakonczeniaChooser.getCalendar(), Double.parseDouble(kwotaLokatyTextField.getText()), new BigDecimal(nrPrzelewu),  nazwaTextField.getText(), aut))
						JOptionPane.showMessageDialog(null, "Dodano nową lokatę dla klienta","Dodano lokatę", JOptionPane.INFORMATION_MESSAGE);
				}
			}
		}
    	
    }
    
    class SzczegolyListener implements ActionListener{
	    String rachunek;
	    String nazwa_konta;
	    String saldo;
	    String dostepne_srodki;
	    Klient k;
	    Rachunek r;
		SzczegolyListener(String rachunek,String nazwa_konta,String saldo,String dostepne_srodki,Klient k,Rachunek r){
			this.rachunek= rachunek;
			this.nazwa_konta=nazwa_konta;
			this.saldo=saldo;
			this.dostepne_srodki=dostepne_srodki;
			this.r=r;
			this.k=k;
		}
	    @Override
	    public void actionPerformed(ActionEvent e) {
	      Szczegoly s = new Szczegoly(r,k);
	      s.setVisible(true);
	    }    	
    }   
}
